function RandomListNode(x){
  this.label = x;
  this.next = null;
  this.random = null;
}
function Clone(pHead)
{
  // write code here
  if(pHead === null) return null
  let cur = pHead
  while(cur){
    let curCopy = new RandomListNode(cur.label)
    curCopy.next = cur.next
    cur.next = curCopy
    cur = curCopy.next
  }
  cur = pHead
  while(cur){
    if(cur.random){
      cur.next.random = cur.random.next
    }
    cur = cur.next.next
  }
  cur = pHead
  let newHead = pHead.next
  while(cur.next){ // 这是因为我们要找的是cur.next作为头部节点
    let temp = cur.next
    cur.next = temp.next
    cur = temp
  }
  return newHead
}
module.exports = {
  Clone : Clone
};